home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
ISSUBST.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-04-16
|
2KB
|
107 lines
DOSSEG
.MODEL LARGE
EXTRN btoh:FAR
EXTRN ReturnValue:FAR
DIRSTRUCTSZ_DOS3 equ 51h ;works for DOS 3.X
DIRSTRUCTSZ_DOS4 equ 58h ;works for DOS 5.0 too!
include extern.inc
.DATA
pname db 'issubst',0
Pool PoolStruct <pname,issubst,,FUNCTION>
PoolStruct <> ;END
.CODE
dtable dd 0
lastdrv db 0
tablesz db DIRSTRUCTSZ_DOS3
public WhenLoaded
WhenLoaded:
mov ah,52h
int 21h ;ES:BX = pointer to DOS info
mov al,es:[bx+21h] ;AL = last drive
mov cs:lastdrv,al ;save
les bx,es:[bx+16h] ;ES:BX = drive table pointer
mov word ptr cs:dtable + 2,es ;save
mov word ptr cs:dtable,bx
mov ah,30h
int 21h ;AL = version high
cmp al,4 ;change size if > 3.X
jb WL1
mov cs:tablesz,DIRSTRUCTSZ_DOS4
WL1:
retf
;
; This routine returns TRUE if a given drive letter is a subst drive, or
; FALSE otherwise.
;
; To call this routine from HyperPAD:
;
; if issubst("F") then beep;
;
issubst: push bp
mov bp,sp
mov ax,[bp+6] ;AX = NumArgs
cmp ax,1
jne _FALSE
mov ah,30h ;dos version number
int 21h
cmp al,3 ;not a subst drive if DOS < 3
jb _FALSE
les bx,[bp+8] ;ES:BX = hDrive
les bx,es:[bx] ;ES:BX = pDrive
mov al,es:[bx] ;AL = drive letter
cmp al,'a' ;convert to upper case
jb IS3
cmp al,'z'
ja IS3
sub al,32
IS3:
sub ax,'A' ;AX: A = 0, B = 1, etc
cmp al,cs:lastdrv ;greater than last drive?
jae _FALSE ;not a subst drive (network?)
cbw ;AX = drive letter
mov bl,cs:tablesz
mul bl ;AX = driveletter * tablesz
les bx,cs:dtable ;ES:BX = drive table
add bx,ax ;ES:BX = drive table entry for that drive
mov ax,es:[bx+43h] ;AX = drive flags
and ax,1000h
jz IS2
mov ax,1 ;AX = TRUE (is a subst drive)
IS2:
push ax ;convert to boolean
call btoh
push dx ;pass to HyperPAD
push ax
call ReturnValue
mov ax,STOP ;don't pass message on
pop bp
retf
_FALSE: xor ax,ax ;return FALSE (not a subst drive)
jmp short IS2
END